<template>


  <SearchTablePage :search-config="baseTableSearchModel" :table-config="baseTableModel" />

</template>

<script lang="ts" setup>
defineOptions({
  name: 'InspectInfoPageData',   //全局别名
  title: '表格页',   //标题
});
// 接口
import InspectInfoApi from '/@/api/webPath/InspectInfoApi.ts';


import FORM_FIELD_TYPE from '/@/constants/FormFieldType';
import VDialog from '/@/utils/dialogUtil.ts'

const router = useRouter();
const baseTable = ref(null as any);
const baseTableSearch = ref(null as any);
const editRef = ref<any>(null);
const townList = ref([])
// 表格搜索初始化searchModel
const baseTableSearchModel = ref({
  columnCount: 4,
  expandLimit: 6,
  autoFit: true,
  columnWidth: '300px',
  labelPosition: 'right',
  labelWidth: '100px',
  items: [ //搜索项初始化

    {
      label: "打分表名称",
      field: "serialName",
      clearable: true,
      type: FORM_FIELD_TYPE.INPUT,

      placeholder: "请输入",

    },

    {
      label: "所属区域",
      field: "areaId",
      clearable: true,
      type: FORM_FIELD_TYPE.CITY_SELECT,
      onChange: async (v) => {
        const data = await InspectInfoApi.getSysTownList({ areaId: v })
        if (data) {
          const { data: townDataList } = data
          townList.value = townDataList.map(x => ({ label: x.town, value: x.areaId }))
        }
      },

      placeholder: "请输入",

    },

    {
      label: "所属乡镇/街道",
      field: "townId",
      clearable: true,
      type: FORM_FIELD_TYPE.SINGLE_LAYER_SELECT,
      options: townList,

      placeholder: "请输入",

    },

    {
      label: "供应商名称",
      field: "name",
      clearable: true,
      type: FORM_FIELD_TYPE.INPUT,

      placeholder: "请输入",

    },

    {
      label: "检查时间",
      field: "inspectTime",
      startDateField: "startInspectTime",
      endDateField: "endInspectTime",
      clearable: true,
      type: FORM_FIELD_TYPE.DATE_RANGE,
      placeholder: "请输入",

      config: {
        props: {   //日期精度配置
          type: "daterange",
          startPlaceholder: "开始日期",
          endPlaceholder: "结束日期",
          format: "YYYY-MM-DD",
        }
      },
    },

  ],

  buttons: [    //功能区域
    {
      name: "导出",
      buttonClass: 'primary',
      width: 100,
      click: ({ row, handlers }) => {   //暴露的方法钩子
        InspectInfoApi.pageDataXls(handlers.getRequestParams(), handlers.getXlsTitle())
      }
    },

    // {
    //   name: "新增",
    //   buttonClass: 'primary',
    //   width: 100,
    //   click: ({ row, handlers }) => {        // 点击回调事件方法钩子，  点击触发

    //     VDialog.open({
    //       title: '新增',

    //       content: { //内容初始形式
    //         type: 'component', //text:"",预留文本
    //         name: '/webPath/inspectInfo/edit',
    //         query: {},

    //       },

    //       callBack: (data: any) => {
    //         handlers.refresh()
    //       },
    //       onClose: () => {
    //         console.log("对话框已关闭");
    //       },
    //     });

    //   },
    // },
    {
      name: "批量删除",
      buttonClass: 'danger',
      width: 100,
      isShow: (row: any) => {
        return false;
      },
      click: () => {   //暴露的方法钩子
        console.log(baseTable.value.getSelection());
      },
    },
  ]
})
// 表格初始化Model
const baseTableModel = ref({
  border: true,
  pagination: true,
  inline: true,
  selectable: true,
  isFullscreen: false,
  minWidth: '200px',
  data: {    //table  初始化
    current: 1,
    size: 10,
    total: 100,
    data: []
  },
  requestData: { api: InspectInfoApi.getPageData, query: {} },   //数据源 参数有效性： 'steady|transient'
  columns: [
    // {
    //   label: "id",
    //   field: "id",
    //   width: 100,
    // },
    {
      label: "打分表序号",
      field: "serialNum",
      width: 180,
    },
    {
      label: "打分表名称",
      field: "serialName",
      width: 180,
    },
    {
      label: "打分表类型",
      field: "serialType",
      width: 180,
    },

    {
      label: "省",
      field: "provinceName",
      width: 180,
    },

    {
      label: "所属区域",
      field: "areaName",
      width: 180,
    },
    {
      label: "所属乡镇/街道",
      field: "townName",
      width: 180,
    },
    {
      label: "供应商名称",
      field: "name",
      width: 180,
    },
    {
      label: "供应商地址",
      field: "address",
      width: 180,
    },
    {
      label: "检查人1",
      field: "examinerOne",
      width: 180,
    },
    {
      label: "检查人2",
      field: "examinerTwo",
      width: 180,
    },
    {
      label: "检查时间",
      field: "inspectTime",
      fieldFormat: "date",
      width: 200,

    },
    {
      label: "扣分制",
      field: "deductPoints",
      width: 120,
    },
    {
      label: "创建时间",
      field: "create_time",
      width: 200,
    },
    {
      label: "更新时间",
      field: "update_time",
      width: 200,
    },
  ],


  actions: [
    // {
    //   name: "详情",

    //   buttonClass: 'primary',
    //   buttonType: 'text',
    //   click: ({ row, index, handlers }) => {

    //     //router.push({name: 'CompanyInfoDetail',})
    //     VDialog.open({
    //       title: '详情',
    //       content: { //内容初始形式
    //         type: 'component', //text:"",预留文本
    //         name: '/inspectInfo/detail',
    //         query: { inspectInfoId: row.id },

    //       },
    //       callBack: (data: any) => {
    //         handlers.refresh()
    //       },
    //       onClose: () => {
    //         console.log("对话框已关闭");
    //       },
    //     });
    //   },
    //   isShow: (row: object) => {
    //     return true;
    //   },
    //   fixed: 'right'
    // },

    // {
    //   name: "编辑",
    //   buttonClass: 'primary',   //按钮颜色控制
    //   buttonType: 'text',      // 按钮风格   text  link  button
    //   isShow: (row: object) => {  //根据业务做动态隐藏张氏
    //     return true
    //   },
    //   click: ({ row, index, handlers }) => {        // 点击回调事件方法钩子，  点击触发

    //     VDialog.open({
    //       title: '编辑',
    //       content: { //内容初始形式
    //         type: 'component', //text:"",预留文本
    //         name: '/inspectInfo/edit',
    //         query: { inspectInfoId: row.id },

    //       },

    //       callBack: (data: any) => {
    //         handlers.refresh()
    //       },
    //       onClose: () => {
    //         console.log("对话框已关闭");
    //       },
    //     });

    //   },
    //   fixed: 'right'
    // }, 
    {
      name: "详情",
      buttonClass: 'primary',   //按钮颜色控制
      buttonType: 'text',      // 按钮风格   text  link  button
      isShow: (row: object) => {  //根据业务做动态隐藏张氏
        return true
      },
      click: ({ row, index, handlers }) => {        // 点击回调事件方法钩子，  点击触发

        VDialog.open({
          title: '详情',
          content: { //内容初始形式
            type: 'component', //text:"",预留文本
            name: '/inspectInfo/edit',
            query: { inspectInfoId: row.id },
          },
          callBack: (data: any) => {
            handlers.refresh()
          },
          onClose: () => {
            console.log("对话框已关闭");
          },
        });

      },
      fixed: 'right'
    },
    {
      name: "下载",
      buttonClass: 'primary',   //按钮颜色控制
      buttonType: 'text',      // 按钮风格   text  link  button
      isShow: (row: object) => {  //根据业务做动态隐藏张氏
        return true
      },
      click: ({ row, index, handlers }) => {
        // 点击回调事件方法钩子，  点击触发
        InspectInfoApi.pageDataXlss(row.id)
      },
      fixed: 'right'
    },

    // {
    //   name: "删除",
    //   buttonClass: 'danger',
    //   buttonType: 'text',
    //   fixed: 'right',
    //   click: ({ row, index, handlers }) => {

    //     $baseConfirm('您确定要删除当前项吗', null, async () => {

    //       const { message } = await InspectInfoApi.del({ inspectInfoIds: row.id })
    //       $baseMessage(message, 'success', 'vab-hey-message-success');

    //       handlers.refresh()

    //     })

    //   }
    // },

  ]

})



onActivated(() => {
})



</script>
